import http from "@/network/http";
import { singer_list } from "@/network/api";
export default {
  namespaced: true,
  state: {
    singerData: {},
    loading: false,
    pullRefresh: false,
  },
  getters: {},
  mutations: {
    setSingerData(state, payload) {
      state.singerData = payload;
    },
    setLoading(state, payload) {
      state.loading = payload;
    },
    setpullRefresh(state, payload) {},
  },
  actions: {
    //获取歌手列表
    async getSingerList(context, payload) {
      payload.offset != 0 && context.commit("setLoading", true);
      const { artists } = await http.get(singer_list, payload);
      const result = artists.map(({ id, name, picUrl }) => ({
        id,
        name,
        picUrl: picUrl + "?param=200x200",
      }));
      context.commit("setSingerData", result);
      context.commit("setLoading", false);
    },
  },
};
